
<template>
    <div class="counter-app">
        <div class="counter-container">
          <h1 class="app-title">点击计数器</h1>
          <div class="counter-display">
            <span class="counter-value">{{ counter }}</span>
            <div class="counter-badge">当前计数</div>
          </div>
    
          <div class="button-group">
            <button 
              class="btn btn-primary" 
              @click="clickMe"
              id="me"
            >
              <span class="btn-icon">?</span>
              点击我
            </button>
            
            <button 
              class="btn btn-secondary" 
              @click="reset"
              id="me2"
            >
              <span class="btn-icon">??</span>
              重置计数
            </button>
          </div>
    
          <div class="stats-panel">
            <div class="stat-item">
              <span class="stat-label">最大计数</span>
              <span class="stat-value">{{ Math.max(counter, maxCount) }}</span>
            </div>
            <div class="stat-item">
              <span class="stat-label">点击次数</span>
              <span class="stat-value">{{ totalClicks }}</span>
            </div>
          </div>
        </div>
      </div>
    </template>
    
    <script setup>
    import { ref, watch } from "vue";
    
    const counter = ref(0);
    const maxCount = ref(0);
    const totalClicks = ref(0);
    
    const clickMe = () => {
      counter.value++;
      totalClicks.value++;
      if (counter.value > maxCount.value) {
        maxCount.value = counter.value;
      }
    }
    
    const reset = () => {
      counter.value = 0;
    }
    
    // 监听计数器变化，添加动画效果
    watch(counter, (newVal, oldVal) => {
      if (newVal !== oldVal) {
        // 可以在这里添加额外的动画逻辑
      }
    });
    </script>
    
    <style scoped>
    .counter-app {
      min-height: 100vh;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      padding: 20px;
    }
    
    .counter-container {
      background: rgba(255, 255, 255, 0.95);
      backdrop-filter: blur(10px);
      border-radius: 24px;
      padding: 40px;
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
      text-align: center;
      max-width: 400px;
      width: 100%;
      border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .app-title {
      color: #2d3748;
      font-size: 2rem;
      font-weight: 700;
      margin-bottom: 30px;
      background: linear-gradient(135deg, #667eea, #764ba2);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    
    .counter-display {
      position: relative;
      margin: 40px 0;
      padding: 20px;
      background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
      border-radius: 20px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }
    
    .counter-value {
      display: block;
      font-size: 4rem;
      font-weight: 800;
      color: white;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
      transition: all 0.3s ease;
    }
    
    .counter-badge {
      position: absolute;
      top: -10px;
      right: 20px;
      background: #4fd1c7;
      color: white;
      padding: 5px 15px;
      border-radius: 15px;
      font-size: 0.8rem;
      font-weight: 600;
      box-shadow: 0 4px 12px rgba(79, 209, 199, 0.4);
    }
    
    .button-group {
      display: flex;
      gap: 15px;
      margin: 30px 0;
      flex-wrap: wrap;
      justify-content: center;
    }
    
    .btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 24px;
      border: none;
      border-radius: 12px;
      font-size: 1rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
      min-width: 140px;
      justify-content: center;
    }
    
    .btn-primary {
      background: linear-gradient(135deg, #4fd1c7, #319795);
      color: white;
    }
    
    .btn-primary:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 25px rgba(79, 209, 199, 0.4);
      background: linear-gradient(135deg, #319795, #4fd1c7);
    }
    
    .btn-secondary {
      background: linear-gradient(135deg, #ed8936, #dd6b20);
      color: white;
    }
    
    .btn-secondary:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 25px rgba(237, 137, 54, 0.4);
      background: linear-gradient(135deg, #dd6b20, #ed8936);
    }
    
    .btn:active {
      transform: translateY(0);
    }
    
    .btn-icon {
      font-size: 1.2rem;
    }
    
    .stats-panel {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 15px;
      margin-top: 30px;
      padding-top: 20px;
      border-top: 1px solid #e2e8f0;
    }
    
    .stat-item {
      background: #f7fafc;
      padding: 15px;
      border-radius: 12px;
      border: 1px solid #e2e8f0;
    }
    
    .stat-label {
      display: block;
      font-size: 0.8rem;
      color: #718096;
      font-weight: 600;
      margin-bottom: 5px;
    }
    
    .stat-value {
      display: block;
      font-size: 1.5rem;
      font-weight: 700;
      color: #2d3748;
    }
    
    /* 响应式设计 */
    @media (max-width: 480px) {
      .counter-container {
        padding: 30px 20px;
        margin: 10px;
      }
      
      .counter-value {
        font-size: 3rem;
      }
      
      .button-group {
        flex-direction: column;
      }
      
      .btn {
        width: 100%;
      }
      
      .stats-panel {
        grid-template-columns: 1fr;
      }
    }
    
    /* 动画效果 */
    @keyframes pulse {
      0% { transform: scale(1); }
      50% { transform: scale(1.05); }
      100% { transform: scale(1); }
    }
    
    .counter-value {
      animation: pulse 0.5s ease;
    }
    </style>
    
    